<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Object - ripper: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">BasicObject
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-const_missing">::const_missing</a>
    <li ><a href="#method-i-add_event">#add_event</a>
    <li ><a href="#method-i-check_arity">#check_arity</a>
    <li ><a href="#method-i-generate_eventids1">#generate_eventids1</a>
    <li ><a href="#method-i-generate_eventids1_h">#generate_eventids1_h</a>
    <li ><a href="#method-i-generate_eventids2_table">#generate_eventids2_table</a>
    <li ><a href="#method-i-grammar">#grammar</a>
    <li ><a href="#method-i-main">#main</a>
    <li ><a href="#method-i-method_missing">#method_missing</a>
    <li ><a href="#method-i-new_var">#new_var</a>
    <li ><a href="#method-i-opt_event">#opt_event</a>
    <li ><a href="#method-i-prelude">#prelude</a>
    <li ><a href="#method-i-process">#process</a>
    <li ><a href="#method-i-read_ids1">#read_ids1</a>
    <li ><a href="#method-i-read_ids1_with_locations">#read_ids1_with_locations</a>
    <li ><a href="#method-i-read_ids2">#read_ids2</a>
    <li ><a href="#method-i-strip_locations">#strip_locations</a>
    <li ><a href="#method-i-usage">#usage</a>
    <li ><a href="#method-i-usercode">#usercode</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Object">
    <h1 id="class-Object" class="class">
      class Object
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="SCRIPT_LINES__">SCRIPT_LINES__
          <dd><p>When a Hash is assigned to <code>SCRIPT_LINES__</code> the contents of files loaded after the assignment will be added as an Array of lines with the file name as the key.</p>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-const_missing" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">const_missing</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="const_missing-source">
            <pre><span class="ruby-comment"># File ripper/tools/dsl.rb, line 84</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">const_missing</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">name</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-add_event" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_event</span><span
                                class="method-args">(event, args, qundef_check = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="add_event-source">
            <pre><span class="ruby-comment"># File ripper/tools/dsl.rb, line 59</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_event</span>(<span class="ruby-identifier">event</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">qundef_check</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">event</span> = <span class="ruby-identifier">event</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/!\z/</span>, <span class="ruby-string">&quot;&quot;</span>)
  <span class="ruby-ivar">@events</span>[<span class="ruby-identifier">event</span>] = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-identifier">vars</span> = []
  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">vars</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">v</span> = <span class="ruby-identifier">new_var</span>
    <span class="ruby-ivar">@code</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{ v }=#{ arg };&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">v</span> = <span class="ruby-identifier">new_var</span>
  <span class="ruby-identifier">d</span> = <span class="ruby-node">&quot;dispatch#{ args.size }(#{ [event, *vars].join(&quot;,&quot;) })&quot;</span>
  <span class="ruby-identifier">d</span> = <span class="ruby-node">&quot;#{ vars.last }==Qundef ? #{ vars.first } : #{ d }&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">qundef_check</span>
  <span class="ruby-ivar">@code</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{ v }=#{ d };&quot;</span>
  <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_arity" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_arity</span><span
                                class="method-args">(h)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="check_arity-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 151</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_arity</span>(<span class="ruby-identifier">h</span>)
  <span class="ruby-identifier">invalid</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">h</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">event</span>, <span class="ruby-identifier">list</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">arity</span><span class="ruby-operator">|</span> <span class="ruby-identifier">arity</span> }.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
      <span class="ruby-identifier">invalid</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-identifier">locations</span> = <span class="ruby-identifier">list</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{line}:#{a}&quot;</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;, &#39;</span>)
      <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;arity crash [event=#{event}]: #{locations}&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">abort</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">invalid</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate_eventids1" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate_eventids1</span><span
                                class="method-args">(ids)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="generate_eventids1-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 94</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_eventids1</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-identifier">buf</span> = <span class="ruby-string">&quot;&quot;</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#include &quot;ruby/ruby.h&quot;\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#include &quot;eventids1.h&quot;\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[struct ripper_parser_ids ripper_parser_ids;\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[void\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[ripper_init_eventids1(void)\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[{\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#define set_id1(name) ripper_id_##name = rb_intern_const(&quot;on_&quot;#name)\n]</span>
  <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>, <span class="ruby-identifier">arity</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">%Q[    set_id1(#{id});\n]</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[}\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[void\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[ripper_init_eventids1_table(VALUE self)\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[{\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[    VALUE h = rb_hash_new();\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[    rb_define_const(self, &quot;PARSER_EVENT_TABLE&quot;, h);\n]</span>
  <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>, <span class="ruby-identifier">arity</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">%Q[    rb_hash_aset(h, intern_sym(&quot;#{id}&quot;), INT2FIX(#{arity}));\n]</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[}\n]</span>
  <span class="ruby-identifier">buf</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate_eventids1_h" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate_eventids1_h</span><span
                                class="method-args">(ids)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="generate_eventids1_h-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 73</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_eventids1_h</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-identifier">buf</span> = <span class="ruby-string">&quot;&quot;</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#ifndef RIPPER_EVENTIDS1\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#define RIPPER_EVENTIDS1\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[void ripper_init_eventids1(void);\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[void ripper_init_eventids1_table(VALUE self);\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[struct ripper_parser_ids {\n]</span>
  <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>, <span class="ruby-identifier">arity</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">%Q[    ID id_#{id};\n]</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[};\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>, <span class="ruby-identifier">arity</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">%Q[#define ripper_id_#{id} ripper_parser_ids.id_#{id}\n]</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#endif /* RIPPER_EVENTIDS1 */\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate_eventids2_table" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate_eventids2_table</span><span
                                class="method-args">(ids)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="generate_eventids2_table-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 124</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_eventids2_table</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-identifier">buf</span> = <span class="ruby-string">&quot;&quot;</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#include &quot;ruby/ruby.h&quot;\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[void\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[ripper_init_eventids2_table(VALUE self)\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[{\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[    VALUE h = rb_hash_new();\n]</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[    rb_define_const(self, &quot;SCANNER_EVENT_TABLE&quot;, h);\n]</span>
  <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">%Q[    rb_hash_aset(h, intern_sym(&quot;#{id}&quot;), INT2FIX(1));\n]</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">%Q[}\n]</span>
  <span class="ruby-identifier">buf</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-grammar" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">grammar</span><span
                                class="method-args">(f, out)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="grammar-source">
            <pre><span class="ruby-comment"># File ripper/tools/preproc.rb, line 90</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">grammar</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">out</span>)
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gets</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">%r&lt;/\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/&gt;</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">DSL</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">$2</span>, (<span class="ruby-node">$1</span> <span class="ruby-operator">||</span> <span class="ruby-string">&quot;&quot;</span>).<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;,&quot;</span>)).<span class="ruby-identifier">generate</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\n&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">%r&lt;/\*%%%\*/&gt;</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;#if 0\n&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">%r&lt;/\*%&gt;</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;#endif\n&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">%r&lt;%\*/&gt;</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\n&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A%%/</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;%%\n&quot;</span>
      <span class="ruby-keyword">return</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-main" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">main</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="main-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 6</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">main</span>
  <span class="ruby-identifier">mode</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">ids1src</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">ids2src</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">output</span> = <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">parser</span> = <span class="ruby-ivar">@parser</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;Usage: #{File.basename($0)} --mode=MODE [--ids1src=PATH] [--ids2src=PATH] [--output=PATH]&quot;</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--mode=MODE&#39;</span>, <span class="ruby-string">&#39;check, eventids1_h, eventids1, or eventids2table.&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">mode</span> = <span class="ruby-identifier">m</span>
  }
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--ids1src=PATH&#39;</span>, <span class="ruby-string">&#39;A source file of event-IDs 1 (parse.y).&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">ids1src</span> = <span class="ruby-identifier">path</span>
  }
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--ids2src=PATH&#39;</span>, <span class="ruby-string">&#39;A source file of event-IDs 2 (eventids2.c).&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">ids2src</span> = <span class="ruby-identifier">path</span>
  }
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--output=PATH&#39;</span>, <span class="ruby-string">&#39;An output file.&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">output</span> = <span class="ruby-identifier">path</span>
  }
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--help&#39;</span>, <span class="ruby-string">&#39;Prints this message and quit.&#39;</span>) {
    <span class="ruby-identifier">puts</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">help</span>
    <span class="ruby-identifier">exit</span> <span class="ruby-keyword">true</span>
  }
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse!</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">err</span>
    <span class="ruby-identifier">usage</span> <span class="ruby-identifier">err</span>.<span class="ruby-identifier">message</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">usage</span> <span class="ruby-string">&#39;no mode given&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">mode</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">mode</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;check&#39;</span>
    <span class="ruby-identifier">usage</span> <span class="ruby-string">&#39;no --ids1src&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ids1src</span>
    <span class="ruby-identifier">usage</span> <span class="ruby-string">&#39;no --ids2src&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ids2src</span>
    <span class="ruby-identifier">h</span> = <span class="ruby-identifier">read_ids1_with_locations</span>(<span class="ruby-identifier">ids1src</span>)
    <span class="ruby-identifier">check_arity</span> <span class="ruby-identifier">h</span>
    <span class="ruby-identifier">ids2</span> = <span class="ruby-identifier">read_ids2</span>(<span class="ruby-identifier">ids2src</span>)
    <span class="ruby-identifier">common</span> = <span class="ruby-identifier">h</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">&amp;</span> <span class="ruby-identifier">ids2</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">common</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">abort</span> <span class="ruby-node">&quot;event crash: #{common.join(&#39; &#39;)}&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">exit</span> <span class="ruby-value">0</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;eventids1_h&#39;</span>
    <span class="ruby-identifier">usage</span> <span class="ruby-string">&#39;no --ids1src&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ids1src</span>
    <span class="ruby-identifier">result</span> = <span class="ruby-identifier">generate_eventids1_h</span>(<span class="ruby-identifier">read_ids1</span>(<span class="ruby-identifier">ids1src</span>))
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;eventids1&#39;</span>
    <span class="ruby-identifier">usage</span> <span class="ruby-string">&#39;no --ids1src&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ids1src</span>
    <span class="ruby-identifier">result</span> = <span class="ruby-identifier">generate_eventids1</span>(<span class="ruby-identifier">read_ids1</span>(<span class="ruby-identifier">ids1src</span>))
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;eventids2table&#39;</span>
    <span class="ruby-identifier">usage</span> <span class="ruby-string">&#39;no --ids2src&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ids2src</span>
    <span class="ruby-identifier">result</span> = <span class="ruby-identifier">generate_eventids2_table</span>(<span class="ruby-identifier">read_ids2</span>(<span class="ruby-identifier">ids2src</span>))
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">output</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">output</span>, <span class="ruby-string">&#39;w&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">result</span>
    }
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-method_missing" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">method_missing</span><span
                                class="method-args">(event, *args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="method_missing-source">
            <pre><span class="ruby-comment"># File ripper/tools/dsl.rb, line 74</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method_missing</span>(<span class="ruby-identifier">event</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/!\z/</span>
    <span class="ruby-identifier">add_event</span>(<span class="ruby-identifier">event</span>, <span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-regexp">/\Aid[A-Z_]/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-identifier">event</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-node">&quot;#{ event }(#{ args.join(&quot;, &quot;) })&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-new_var" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new_var</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new_var-source">
            <pre><span class="ruby-comment"># File ripper/tools/dsl.rb, line 51</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">new_var</span>
  <span class="ruby-node">&quot;v#{ @vars += 1 }&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-opt_event" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">opt_event</span><span
                                class="method-args">(event, default, addend)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="opt_event-source">
            <pre><span class="ruby-comment"># File ripper/tools/dsl.rb, line 55</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">opt_event</span>(<span class="ruby-identifier">event</span>, <span class="ruby-identifier">default</span>, <span class="ruby-identifier">addend</span>)
  <span class="ruby-identifier">add_event</span>(<span class="ruby-identifier">event</span>, [<span class="ruby-identifier">default</span>, <span class="ruby-identifier">addend</span>], <span class="ruby-keyword">true</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prelude" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">prelude</span><span
                                class="method-args">(f, out)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="prelude-source">
            <pre><span class="ruby-comment"># File ripper/tools/preproc.rb, line 54</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">prelude</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">out</span>)
  <span class="ruby-ivar">@exprs</span> = {}
  <span class="ruby-identifier">lex_state_def</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gets</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A%%/</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;%%\n&quot;</span>
      <span class="ruby-keyword">return</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A%token/</span>, <span class="ruby-regexp">/\A} &lt;node&gt;/</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/&lt;\w+&gt;/</span>, <span class="ruby-string">&#39;&lt;val&gt;&#39;</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A%type/</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/&lt;\w+&gt;/</span>, <span class="ruby-string">&#39;&lt;val&gt;&#39;</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^enum lex_state_(?:bits|e) \{/</span>
      <span class="ruby-identifier">lex_state_def</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^\}/</span>
      <span class="ruby-identifier">lex_state_def</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">lex_state_def</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">line</span>
      <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^\s*(EXPR_\w+),\s+\/\*(.+)\*\//</span>
        <span class="ruby-ivar">@exprs</span>[<span class="ruby-node">$1</span>.<span class="ruby-identifier">chomp</span>(<span class="ruby-string">&quot;_bit&quot;</span>)] = <span class="ruby-node">$2</span>.<span class="ruby-identifier">strip</span>
      <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^\s*(EXPR_\w+)\s+=\s+(.+)$/</span>
        <span class="ruby-identifier">name</span> = <span class="ruby-node">$1</span>
        <span class="ruby-identifier">val</span> = <span class="ruby-node">$2</span>.<span class="ruby-identifier">chomp</span>(<span class="ruby-string">&quot;,&quot;</span>)
        <span class="ruby-ivar">@exprs</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-string">&quot;equals to &quot;</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">val</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&quot;(&quot;</span>) <span class="ruby-operator">?</span> <span class="ruby-node">&quot;&lt;tt&gt;#{val}&lt;/tt&gt;&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;+#{val}+&quot;</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-process" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">process</span><span
                                class="method-args">(f, out, path, template)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="process-source">
            <pre><span class="ruby-comment"># File ripper/tools/preproc.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">process</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">out</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">template</span>)
  <span class="ruby-identifier">prelude</span> <span class="ruby-identifier">f</span>, <span class="ruby-identifier">out</span>
  <span class="ruby-identifier">grammar</span> <span class="ruby-identifier">f</span>, <span class="ruby-identifier">out</span>
  <span class="ruby-identifier">usercode</span> <span class="ruby-identifier">f</span>, <span class="ruby-identifier">out</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">template</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_ids1" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_ids1</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="read_ids1-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 142</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_ids1</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">strip_locations</span>(<span class="ruby-identifier">read_ids1_with_locations</span>(<span class="ruby-identifier">path</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_ids1_with_locations" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_ids1_with_locations</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="read_ids1_with_locations-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 165</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_ids1_with_locations</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">h</span> = {}
  <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">f</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\A\#\s*define\s+dispatch/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">line</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/ripper_dispatch/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">line</span>
      <span class="ruby-identifier">line</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/\bdispatch(\d)\((\w+)/</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arity</span>, <span class="ruby-identifier">event</span><span class="ruby-operator">|</span>
        (<span class="ruby-identifier">h</span>[<span class="ruby-identifier">event</span>] <span class="ruby-operator">||=</span> []).<span class="ruby-identifier">push</span> [<span class="ruby-identifier">f</span>.<span class="ruby-identifier">lineno</span>, <span class="ruby-identifier">arity</span>.<span class="ruby-identifier">to_i</span>]
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r&lt;/\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/&gt;</span>
        <span class="ruby-identifier">gen</span> = <span class="ruby-constant">DSL</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">$2</span>, (<span class="ruby-node">$1</span> <span class="ruby-operator">||</span> <span class="ruby-string">&quot;&quot;</span>).<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;,&quot;</span>))
        <span class="ruby-identifier">gen</span>.<span class="ruby-identifier">generate</span>
        <span class="ruby-identifier">gen</span>.<span class="ruby-identifier">events</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">event</span>, <span class="ruby-identifier">arity</span><span class="ruby-operator">|</span>
          (<span class="ruby-identifier">h</span>[<span class="ruby-identifier">event</span>] <span class="ruby-operator">||=</span> []).<span class="ruby-identifier">push</span> [<span class="ruby-identifier">f</span>.<span class="ruby-identifier">lineno</span>, <span class="ruby-identifier">arity</span>.<span class="ruby-identifier">to_i</span>]
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  }
  <span class="ruby-identifier">h</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_ids2" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_ids2</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="read_ids2-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 186</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_ids2</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">src</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>}
  <span class="ruby-identifier">ids2</span> = <span class="ruby-identifier">src</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/ID\s+ripper_id_(\w+)/</span>).<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">sort</span>
  <span class="ruby-identifier">diff</span> = <span class="ruby-identifier">src</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/set_id2\((\w+)\);/</span>).<span class="ruby-identifier">flatten</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">ids2</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">diff</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">abort</span> <span class="ruby-node">&quot;missing scanner IDs: #{diff}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">ids2</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-strip_locations" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">strip_locations</span><span
                                class="method-args">(h)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="strip_locations-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 146</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">strip_locations</span>(<span class="ruby-identifier">h</span>)
  <span class="ruby-identifier">h</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">event</span>, <span class="ruby-identifier">list</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">event</span>, <span class="ruby-identifier">list</span>.<span class="ruby-identifier">first</span>[<span class="ruby-value">1</span>]] }\
      .<span class="ruby-identifier">sort_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">event</span>, <span class="ruby-identifier">arity</span><span class="ruby-operator">|</span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">to_s</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-usage" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">usage</span><span
                                class="method-args">(msg)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="usage-source">
            <pre><span class="ruby-comment"># File ripper/tools/generate.rb, line 67</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">usage</span>(<span class="ruby-identifier">msg</span>)
  <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">msg</span>
  <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">help</span>
  <span class="ruby-identifier">exit</span> <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-usercode" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">usercode</span><span
                                class="method-args">(f, out, path, template)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="usercode-source">
            <pre><span class="ruby-comment"># File ripper/tools/preproc.rb, line 110</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">usercode</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">out</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">template</span>)
  <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;erb&#39;</span>
  <span class="ruby-identifier">lineno</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">src</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">compiler</span> = <span class="ruby-constant">ERB</span><span class="ruby-operator">::</span><span class="ruby-constant">Compiler</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;%-&#39;</span>)
  <span class="ruby-identifier">compiler</span>.<span class="ruby-identifier">put_cmd</span> = <span class="ruby-identifier">compiler</span>.<span class="ruby-identifier">insert_cmd</span> = <span class="ruby-string">&quot;out.&lt;&lt;&quot;</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">template</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">out</span>.<span class="ruby-identifier">clear</span>
      <span class="ruby-identifier">lineno</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">lineno</span>
      <span class="ruby-identifier">src</span>, = <span class="ruby-identifier">compiler</span>.<span class="ruby-identifier">compile</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>)
      <span class="ruby-identifier">path</span> = <span class="ruby-identifier">template</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">lineno</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">lineno</span>
    <span class="ruby-identifier">src</span>, = <span class="ruby-identifier">compiler</span>.<span class="ruby-identifier">compile</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">binding</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">lineno</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

